package com.study.ctripapollo.service;

import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author flwu
 * @date 2020/3/16 5:00 PM
 * @MOTTO 保持空和敬畏
 */
@Service
public class ListenService {

    private static final Logger log = LoggerFactory.getLogger(ListenService.class);

    @ApolloConfigChangeListener
    public void onChange(ConfigChangeEvent changeEvent) {
        Set<String> keys = changeEvent.changedKeys();
        for (String key : keys) {
            log.error(changeEvent.getChange(key).toString());
        }
    }
}
